package com.ruoyi.contarct.enums;

import com.ruoyi.common.utils.DateUtils;

import java.util.Date;

public enum DateUtilType {
    DAY(1, "天"),
    MONTH(2, "月"),
    QUARTER(3, "季度"),
    HALFYEAR(4, "半年"),
    YEAR(5, "年");

    DateUtilType(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    private int code;

    private String msg;

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }


    public static Date getEndDate(Date start,int n,int type){
        Date endDate = new Date();
        switch (type){
            case 1://天
                endDate = DateUtils.getBeforeSomeDaysDate(start,n);
                break;
            case 2://月
                endDate = DateUtils.getBeforeSomeMonthsDate(start,n);
                break;
            case 3://季度
                endDate = DateUtils.getBeforeSomeMonthsDate(start,n*3);
                break;
            case 4://半年
                endDate = DateUtils.getBeforeSomeMonthsDate(start,n*6);
                break;
            case 5://年
                endDate = DateUtils.getBeforeSomeYearDate(start,n);
                break;
        }
        return endDate;
    }
}
